package com.oocl.homework.crm.command;

import com.oocl.homework.crm.datastruct.Executeable;
import com.oocl.homework.crm.model.Filterable;
import com.oocl.homework.crm.model.Result;
import com.oocl.homework.crm.util.CommandUtil;

public class UpdateCommand<T> extends Command<T>{

	public UpdateCommand(String command) {
		super(command);
	}
	

	@Override
	public void filter(Filterable filterable) {
		super.filter(filterable);
		super.filterId();
		if(result.getCode()==-1){
			return;
		}else{
			splitCommandParameterAttributes();
			if(result.getCode()==-1){
				return ;
			}
			Result filterResult = filterable.filter(getCommandParameterAttributes());
			if (filterResult.getCode()==-1) {
				result =  filterResult;
				return;
			}
		}
		
	}
	
	@Override
	public void executeCommand(Executeable<T> executeable,T t) {
		super.executeCommand(executeable, t);
		executeable.update(t);
		
	}

	@Override
	public void display() {
		super.display();
		CommandDoc.printUpdateCommandHelp();
		
	}

}
